home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 25
/
Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso
/
Aminet
/
dev
/
e
/
doomwad.lha
/
DoomWAD.doc
next >
Wrap
Text File
|
1998-03-15
|
7KB
|
240 lines
Peter Gordon Presents
------------------------------- DOOMWAD.M ----------------------------------
An Amiga E module to load and decode Doom 1 & 2 .WAD files.
1. INTRODUCTION
DoomWAD.m was written because I wanted to write a level editor for Doom
basically :). I started work on it but the actual level format of Doom
was far to complex for me to get my head around :(
I'm releasing the work I've done already so that other people can write
Doom editors/utils for the Amiga. So go to it :)
2. WHATS IN THE ARCHIVE?
Well, this:
modules/doomwad.m - My routines for opening/decoding doom wad files
modules/doomwad.e - Source code for said module
DoomSpec/DmSpec16.txt - The (very nearly) complete file format of Doom 1
and 2 .WADs. Be careful, this is real brain
death stuff :)
Examples/endoomview - A viewer of ENDOOM lumps (the messages that come
up when you quit doom)
Examples/endoomview.e - Source code for endoomview
Examples/waddir - A util to show all the "lumps" in a doom wad
Examples/waddir.e - Source code for waddir
DoomWAD.doc - This file
3. DISTRIBUTION, USAGE AND DISCLAIMER
The author provides no warranties of any kind either express or implied.
Use all this stuff at your own risk.
You can do what the hell you like with these files, with one condition,
you credit me as the original author of the routines.
4. PROGRAMMING STUFF
If you dont understand any of this stuff, a quick browse through DmSpec16.txt
should help :)
OK, so whats in DoomWAD.m? Well, first off there is a whole load of
constants that give more readable names to all the "things".
A thing is a sprite, or a player start, or a bonus pickup etc. etc.
It also has the following routines:
----------------------------------------------------------------------------
NAME openwad
USAGE handle := openwad( filename )
| |
PTR TO wadhandle PTR TO CHAR
This routine returns a pointer to a WADHandle structure, which is:
OBJECT wadhandle
dosh, -> The AmigaDOS handle to the actual .WAD file
iwad, -> TRUE if the WAD is an IWAD, false if its a PWAD
numlumps, -> Number of "lumps" in the wad
dirstrt -> Offset to the start of the directory
ENDOBJECT
It will return NIL if it cannot open the wad.
----------------------------------------------------------------------------
NAME closewad
USAGE closewad( handle )
|
PTR TO wadhandle
Closes a wad opened with openwad()
----------------------------------------------------------------------------
NAME readentry
USAGE readentry( offset, handle, dirblock )
| |
| PTR TO dirblock
PTR TO wadhandle
This routine will fill out a dirblock object from the offset specified.
A dirblock object is:
OBJECT dirblock
offset, -> Lump offset from start of WAD
size, -> Size of lump
name[8]:ARRAY OF CHAR -> name of lump
ENDOBJECT
So, to read the first entry in the wad directory into a previously allocated
dirblock structure called dbk, using an open wadhandle called wdh, you
would do:
readentry(0, wdh, dbk)
To read the next entry, you would do:
readentry(16, wdh, dbk)
(each direntry is 16 bytes long).
NOTES
This routine will never fail. If you give it an offset to a location that
isnt a direntry, the dirblock will be filled with garbage.
----------------------------------------------------------------------------
NAME findentry
USAGE success, diroffset := findentry( entryname, handle, dirblock)
This routine will scan through the wad looking for a specific lump by name.
It will return TRUE in success if it finds it, and FALSE if it doesnt.
If success is TRUE, dirblock will be filled out to point to the lump you
were searching for. If for some reason you need to re-read the dirblock,
you can do the following:
success, diroffset := findentry('ENDOOM',wdh,dbk)
IF(success)
/*
** Do some stuff with the ENDOOM lump
*/
/* Oh no, dirblock has been trashed :-) */
dbk.offset:=0
/* Find that entry again */
readentry(diroffset*16,wdh,dbk)
ENDIF
----------------------------------------------------------------------------
NAME readthings()
USAGE thinglist := readthings( levelname, handle )
| |
PTR TO thing PTR TO wadhandle
This routine will decode a THINGS lump for a specified level into a big
"list" of thing objects. A thing object is:
OBJECT thing
nextthing:PTR TO thing, -> Pointer to next thing in list, or 0
prevthing:PTR TO thing, -> Pointer to previous thing in list, or 0
x:INT, -> X position of thing
y:INT, -> Y position of thing
angle:INT, -> Angle of thing
type:INT, -> type of thing (e.g. shotgun, playerstart)
options:INT -> options
ENDOBJECT
So, for a Doom 1 WAD, you could do:
thinglist:=readthings('E1M1',wdh)
IF(thinglist)
current_thing:=thinglist
WHILE(current_thing<>0)
WriteF('Thing \d at position (\d,\d)\n',current_thing.type,current_thing.x,current_thing.y)
current_thing:=current_thing.nextthing
ENDWHILE
freethings(thinglist)
ENDIF
Which would display the position and type of all the things on episode 1
map 1.
----------------------------------------------------------------------------
NAME freethings
USAGE freethings( thinglist )
|
PTR TO thing
This routine frees a thinglist allocated by readthings()
----------------------------------------------------------------------------
NAME motoword
USAGE motorola_word := motoword( intel_word )
OR
intel_word := motoword( motorola_word )
Because all the words in a Doom wad use intel "Little Endian" words, we
need to convert them before we play with them. Any intel word passed to
this routine will be returned as a motorola word, and vice versa.
----------------------------------------------------------------------------
NAME motolong
USAGE motorola_long := motolong( intel_long )
OR
intel_long := motoword( motorola_long )
Same as motoword() but for longwords
5. USING THE EXAMPLES
To use Endoomview or Waddir, simply specify a .WAD, e.g:
endoomview hd1:Games/doom/doomu.wad
waddir hd1:games/doom2/doom2.wad
If you have a font called ansi.font in your fonts dir, endoomview will
use it to get all the proper IBM chars, otherwise it'll just use topaz.
6. THATS ALL FOLKS
I cant be arsed to write any more gibberish :) If you improve doomwad.m,
or need help using it, e-mail me at:
the.moosuck@borghome.demon.co.uk
PLEASE send me your improved doomwad.e source codes if you make any :)